package com.example.idphotogenerator.controller;

import com.example.idphotogenerator.service.PhotoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/photos")
public class PhotoController {

    @Autowired
    private PhotoService photoService;

    @PostMapping(value = "/generate", consumes = "multipart/form-data")
    public String generateIdPhoto(@RequestParam("input_image") MultipartFile inputImage,
                                   @RequestParam("width") int width,
                                   @RequestParam("height") int height) {
        return photoService.generateIdPhoto(inputImage, width, height);
    }

        @PostMapping(value = "/add_background", consumes = "application/json")
    public String addBackground(@RequestBody BackgroundRequest request) {
        return photoService.addBackground(request.getImageBase64(), request.getColor());
    }

    public static class BackgroundRequest {
        private String imageBase64;
        private String color;

        // Getters and Setters
        public String getImageBase64() {
            return imageBase64;
        }

        public void setImageBase64(String imageBase64) {
            this.imageBase64 = imageBase64;
        }

        public String getColor() {
            return color;
        }

        public void setColor(String color) {
            this.color = color;
        }
    }
} 